using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.OleDb;
using System.Data;

namespace GiaoDien
{
    class TacGiaDAO
    {
		#region ThemTacGia
		public static bool ThemTacGia(TacGiaDTO tgDTO)
        {
            string sQuery = "insert into TacGia(Matacgia,Tentacgia) values(" + tgDTO.MaTacGia + ",'" + tgDTO.TenTacGia + "')";
            OleDbConnection con = DataProvider.taoKetNoi();
            bool ketqua = DataProvider.executeNonQuery(sQuery, con);
            DataProvider.dongKetNoi(con);
            return ketqua;
        }
		#endregion
		
        #region LayTacGia
        public static DataTable LayTacGia(TacGiaDTO tgDTO)
        {
            string sQuery = "select Tentacgia from TacGia order by Matacgia";
            OleDbConnection con = DataProvider.taoKetNoi();
            DataTable da = DataProvider.layDataTable(sQuery, con);
            DataProvider.dongKetNoi(con);
            return da;
        }
        #endregion

		#region CapNhapTacGia
		public static bool CapNhapTacGia(TacGiaDTO tgDTO)
        {
            string sQuery = "update TacGia set Tentacgia='" + tgDTO.TenTacGia + "' where Matacgia=" + tgDTO.MaTacGia;
            OleDbConnection con = DataProvider.taoKetNoi();
            bool ketqua = DataProvider.executeNonQuery(sQuery, con);
            DataProvider.dongKetNoi(con);
            return ketqua;
        }
		#endregion
		
		#region XoaTacGia
		public static bool XoaTacGia(TacGiaDTO tgDTO)
        {
            string sQuery = "delete from TacGia where Matacgia=" + tgDTO.MaTacGia;
            OleDbConnection con = DataProvider.taoKetNoi();
            bool ketqua = DataProvider.executeNonQuery(sQuery, con);
            DataProvider.dongKetNoi(con);
            return ketqua;
        }
		#endregion
    }
}
